/**
 * 
 */
package com.gwcloud.leetcode.tags.dp;

/**
 * @ClassName   : Leetcode0309 
 * @author      : ganwei 
 * @date        : 2020年5月17日
 * @Description : Leetcode0309 最佳买卖股票时机含冷冻期
 */
public class Leetcode0309 {
	/**
	 * -动态规划干股票
	 */
    public int maxProfit(int[] prices) {
    	int n = prices.length;
    	int d_i_0 = 0;
    	int d_i_1 = Integer.MIN_VALUE;
    	int d_pre_0 = 0;
    	for(int i = 0; i < n; i++){
    		int temp = d_i_0;
    		d_i_0 = Math.max(d_i_0, d_i_1 + prices[i]);
    		d_i_1 = Math.max(d_i_1, d_pre_0 - prices[i]);
    		d_pre_0 = temp;
    	}
    	return d_i_0;
    }
    
    public static void main(String[] args){
    	
    }
}
